<div class="container-fluid">
    <div class="wrapper">
        <div class="panel" id="nav">
            <div class="panel-heading"><h3 class="panel-title">新建储位</h3></div>
            <div class="panel-body">
                <form method="post" class="form-horizontal">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-md-4 control-label required">储位名称</label>
                            <div class="col-md-8">
                                <input type="text" class="form-control" name="storage_position" style="width: 30%" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-4 control-label required">储位位置</label>
                            <div class="col-md-8">
                                <input type="text" class="form-control" name="position" style="width: 30%" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-4 control-label required">是否退税</label>
                            <div class="col-md-8">
                                <select class="form-control" name="export_tax_rebate" style="width: 30%">
                                    <option value="0">非出口退税</option>
                                    <option value="1">出口退税</option>
                                </select>
                            </div>
                        </div>
                        <!-- <div class="form-group">
                            <label class="col-md-4 control-label required">中转仓</label>
                            <div class="col-md-8">
                                <select class="form-control" name="transfer_hopper_id" style="width: 30%">
                                    <option value="">---请选择---</option>
                                    <option value="0">东莞中转仓</option>
                                </select>
                            </div>
                        </div> -->
                        <div class="form-group">
                            <label class="col-md-4 control-label required">商业主体</label>
                            <div class="col-md-8">
                                <select class="form-control" name="enterprise_dominant" style="width: 30%">
                                    <option value="">---请选择---</option>
                                    <volist name="enterprise_dominant" id="item">
                                        <option value="{$key}">{$item}</option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-4 control-label required">状态</label>
                            <div class="col-md-8">
                                <select class="form-control" name="status">
                                    <option value="1">启用</option>
                                    <option value="0">禁用</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-4 control-label">备注</label>
                            <div class="col-md-8">
                                <textarea class="form-control" cols="50" rows="4" name="remark"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3 col-md-offset-5">
                            <button class="btn btn-primary btn-save" type="button">提交</button>
                            <button class="btn btn-white" type="reset">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $("input").blur(function(){
            $(this).val($.trim($(this).val()));
        });


        $(".btn-save").click(function () {
            if ($.trim($('input[name="storage_position"]').val()) == '') {
                layer.msg('储位名称不能为空！', {offset: 250});
                return;
            } 

            if ($.trim($('input[name="position"]').val()) == '') {
                layer.msg('储位位置不能为空！', {offset: 250});
                return;
            }

            var _self = $(this);
            _self.html('提交中...');
            $.ajax({
                type: "post",
                url: 'Warehouse/StockIn/add_storage',
                data: $("form").serialize(),
                dataType: "json",
                success: function (result) {
                    if (result.status) {
                        layer.msg(result.info, {icon: 6});
                        setTimeout(function () {
                            window.location.href = 'Warehouse/StockIn/storage_lists';
                        }, 2000);
                    } else {
                        layer.msg(result.info, {icon: 5});
                    }
                    _self.html('提交');
                }
            });
        });
    </script>